public class 无重复字符的最长子串 {
    public int lengthOfLongestSubstring(String ss) {
        char[] s = ss.toCharArray();
        int[] hash = new int[256];
        int ans = 0;
        int l = 0;
        for (int r = 0;r < s.length;r++) {
            char ch = s[r];
            if(hash[ch]++ > 0) {
                while (--hash[s[l++]] != 1) {
                }
            }
            ans = Math.max(ans,r - l + 1);
        }
        return ans;
    }
}
